package com.wms.common;

import lombok.Data;

@Data
public class Result {
    private int code;// 编码 200/400

    private String msg;// 成功/失败

    private Long total;// 总记录数

    private Object data;// 数据

    public static Result fail(){
        return result(400, "失败", null,0L);
    }

    public static Result success(){
        return result(200, "成功",null,0L);
    }

    public static Result success(Object data){
        return result(200, "成功", data,0L);
    }

    public static Result success(Object data, Long total){
        return result(200, "成功", data,total);
    }

    private static Result result(int code, String msg, Object data,Long total){
        Result result = new Result();
        result.setData(data);
        result.setCode(code);
        result.setMsg(msg);
        result.setTotal(total);
        return result;
    }
}
